package com.coconutwater.nft;

import com.coconutwater.nft.block.BlockRailTransfer;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;

@Mod(modid = NFTMod.MODID, version = NFTMod.VERSION)
public class NFTMod {
    public static final String MODID = "nft";
    public static final String VERSION = "1.0.0";

    public static BlockRailTransfer mBlockRailTransfer;
    public static int RADIUS;
    private Configuration mConfiguration;

    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {

        GameRegistry.registerBlock(mBlockRailTransfer = new BlockRailTransfer(), "nft_rail");
        GameRegistry.addShapelessRecipe(new ItemStack(mBlockRailTransfer), Blocks.rail, Items.ender_pearl);
        mConfiguration = new Configuration(event.getSuggestedConfigurationFile());
        syncConfig();


    }

    public void syncConfig() {
        try {
            mConfiguration.load();

            Property radiusProp = mConfiguration.get(Configuration.CATEGORY_GENERAL, // What category will it be saved to, can be any string
                    "radius",
                    8,
                    "传送检测半径");
            RADIUS = radiusProp.getInt();

        } catch (Exception e) {
            System.out.println("Error:" + e.getMessage());
        } finally {
            mConfiguration.save();
        }
    }
}
